package com.sanhe.rfmuscle.activity.work;

import static com.menu.app.util.FunctionCode.START1;
import static com.menu.app.util.FunctionCode.START2;

import androidx.annotation.NonNull;
import androidx.core.view.MenuProvider;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;

import com.menu.app.activity.base.MenuBaseActivity;
import com.menu.app.it.M808;
import com.menu.app.util.port.SerialManage;
import com.sanhe.rfmuscle.event.Event;
import com.sanhe.rfmuscle.event.SingleEvent;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public abstract class BaseWorkActivity extends MenuBaseActivity implements M808 {

    @Override
    protected byte[][] getInterest() {
        return new byte[0][];
    }

    @Override
    protected void updateUI() {

    }

    @Override
    public void exit() {
        finish();
    }

    @Override
    public String getPageIndex() {
        return null;
    }

    @Override
    public void addMenuProvider(@NonNull MenuProvider provider, @NonNull LifecycleOwner owner, @NonNull Lifecycle.State state) {

    }

    @Override
    protected void sendTouchEvent(byte data_H, byte data_L) {
        byte[] tmp = {START1, START2, 6, -125, 16, 1, 1, 0, data_L};
        SerialManage.getInstance().send(tmp);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(SingleEvent event) {
        if (popMenu != null) {
            popMenu.updateFlow(Event.singleEvent.getValue() + "");
        }
    }

}
